//
//  pictureCollectionCell.m
//  YouGoWeGo
//
//  Created by 范业君 on 14-11-25.
//  Copyright (c) 2014年 LiuFei. All rights reserved.
//

#import "pictureCollectionCell.h"
#import "pictureModel.h"
#import "UIImageView+WebCache.h"
@implementation pictureCollectionCell
- (void)dealloc
{
    [_picModel release];
    [_addLabel release];
    [_image release];
    [self removeObserver:self forKeyPath:@"picModel"];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if ( self) {
        self.image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.width)];
        [_image.layer setCornerRadius:5];
        [_image.layer setMasksToBounds:YES];
        [self.contentView addSubview:_image];
        [_image release];
        
        
        self.addLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,10, 100, 20)];
        [self.addLabel setFont:[UIFont systemFontOfSize:12]];
        [_addLabel numberOfLines];
        [_addLabel setTextColor:[UIColor whiteColor]];
        [self.contentView addSubview:_addLabel];
        [_addLabel release];
    }
    
    [self addObserver:self forKeyPath:@"picModel" options:NSKeyValueObservingOptionNew context:nil];
    return self;
}



- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"picModel"]) {
        [self.image setImageWithURL:[NSURL URLWithString:self.picModel.photo_w640]];
       
        [self.addLabel setText:[self.picModel.poi objectForKey:@"name"]];
    }
    
}
@end
